const files = require.context('.', true, /\.js$/)

const routes = files.keys().reduce((tempRoutes, path) => {
  if (path !== './index.js') {
    tempRoutes.push(files(path).default)
  }
  return tempRoutes
}, [])

routes.push({
  path: '*',
  redirect: '/error',
  hidden: true,
})

export default routes
